import type { Ref } from 'vue'
import { inject, provide, toRef } from 'vue'

const LOCALE_KEY = Symbol('locale')

export const ZH_CN = {
  button: {
    add: '新增',
    view: '查看',
    edit: '编辑',
    del: '删除',
    search: '搜索',
    clear: '清空',
    expand: '展开',
    collapse: '收起',
    save: '保存',
    prev: '上一步',
    next: '下一步',
  },
  table: {
    serialNo: '#',
    actions: '操作',
  },
  title: {
    add: '新增',
    view: '查看',
    edit: '编辑',
  },
  tooltip: {
    stripe: '条纹',
    size: '尺寸',
    small: '紧凑',
    medium: '默认',
    large: '宽松',
    fullscreenMaximize: '全屏',
    fullscreenMinimize: '还原',
    refresh: '刷新',
    import: '导入',
    export: '导出',
    columnSetting: '列设置',
    reset: '重置',
    fixed2left: '固定到左侧',
    fixed2right: '固定到右侧',
  },
}

export type NvLocale = typeof ZH_CN

export const EN_US: NvLocale = {
  button: {
    add: 'Add',
    view: 'View',
    edit: 'Edit',
    del: 'Delete',
    search: 'Search',
    clear: 'Clear',
    expand: 'Expand',
    collapse: 'Collapse',
    save: 'Save',
    prev: 'Previous',
    next: 'Next',
  },
  table: {
    serialNo: '#',
    actions: 'Actions',
  },
  title: {
    add: '新增',
    view: '查看',
    edit: '编辑',
  },
  tooltip: {
    stripe: 'Stripe',
    size: 'Size',
    small: 'Compact',
    medium: 'Default',
    large: 'Loose',
    fullscreenMaximize: 'Fullscreen',
    fullscreenMinimize: 'Restore',
    refresh: 'Refresh',
    import: 'Import',
    export: 'Export',
    columnSetting: 'Column Setting',
    reset: 'Reset',
    fixed2left: 'Fixed to Left',
    fixed2right: 'Fixed to Right',
  },
}

export function provideLocale(locale: Ref<NvLocale>) {
  provide(LOCALE_KEY, locale)
}

export function useLocale() {
  return inject(LOCALE_KEY, toRef(ZH_CN))
}
